package com.googlecode.framework.orm.hibernate;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.LockOptions;
import org.springframework.dao.DataAccessException;

import com.googlecode.framework.core.pagination.OrderablePagination;
import com.googlecode.framework.dao.Persistable;
import com.googlecode.framework.orm.OrmExecutor;
import com.googlecode.framework.orm.hibernate.criterion.SafeDetachedCriteria;

public interface HibernateOrmExecutor extends OrmExecutor {
    
    <E extends Persistable> E get(Class<E> clazz, Serializable id) throws DataAccessException;
    
    <E extends Persistable> E get(Class<E> clazz, Serializable id, LockOptions lockOptions) throws DataAccessException;
    
    <E extends Persistable> E get(Class<E> clazz, Serializable id, String[] initFields) throws DataAccessException;
    
    <E extends Persistable> E get(Class<E> clazz, Serializable id, LockOptions lockOptions, String[] initFields) throws DataAccessException;
    
    Serializable save(Persistable entity) throws DataAccessException;
    
    Serializable[] save(Persistable[] entities) throws DataAccessException;
    
    Collection<Serializable> save(Collection<Persistable> entities) throws DataAccessException;
    
    void update(Persistable entity) throws DataAccessException;
    
    void update(Persistable[] entities) throws DataAccessException;
    
    void update(Collection<Persistable> entities) throws DataAccessException;
    
    void saveOrUpdate(Persistable entity) throws DataAccessException;
    
    void saveOrUpdate(Persistable[] entities) throws DataAccessException;
    
    void saveOrUpdate(Collection<Persistable> entities) throws DataAccessException;
    
    void delete(Class<? extends Persistable> clazz, Serializable id) throws DataAccessException;
    
    void delete(Persistable entity) throws DataAccessException;
    
    void delete(Persistable[] entities) throws DataAccessException;
    
    void delete(Collection<Persistable> entities) throws DataAccessException;
    
    <E extends Persistable> List<E> executeForObjectList(SafeDetachedCriteria criteria);
    
    <E extends Persistable> List<E> executeForObjectList(SafeDetachedCriteria criteria, OrderablePagination op);
    
    <E extends Persistable> List<E> executeForObjectList(SafeDetachedCriteria criteria, OrderablePagination op, String[] initFields);
    
    <E extends Persistable> List<E> executeForObjectList(final SafeDetachedCriteria criteria, final int offset, final int length);
    
    <E extends Persistable> List<E> executeForObjectList(final SafeDetachedCriteria criteria, final int offset, final int length, final String[] initFields);
    
    <E extends Persistable> E executeForObject(SafeDetachedCriteria criteria);
    
    <E extends Persistable> E executeForObject(SafeDetachedCriteria criteria, String[] initFields);
    
    <E extends Persistable> List<E> executeForObjectListByHql(String hql, Object[] params);
    
    <E extends Persistable> List<E> executeForObjectListByHql(String hql, Object[] params, OrderablePagination op);
    
    <E extends Persistable> List<E> executeForObjectListByHql(String hql, Object[] params, OrderablePagination op, String[] initFields);

    <E extends Persistable> E executeForObjectByHql(String hql, Object[] params);
    
    <E extends Persistable> E executeForObjectByHql(String hql, Object[] params, String[] initFields);
    
    int bulkUpdate(String queryString) throws DataAccessException;

    int bulkUpdate(String queryString, Object... values) throws DataAccessException;

    void flush() throws DataAccessException;
    
    void clear() throws DataAccessException;
}
